<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="__PUBLIC__/echarts/echarts.min.js"></script>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
</head>
<style>

    .layui-table th, .layui-table td{
        padding: 9px 6px;
        text-align: center;
    }
    .sp p{
        display: inline-block;
        width: 50%;
        float: left;
        height: 35px;
        /*border: 0.5px solid #777777;*/
    }
    /*.layui-table th{*/
    /**/
    /*}*/
    /*.layui-form select{*/
    /*display: inline-block;*/
    /*}*/
</style>
<body>
<div class="layui-fluid main">
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <div class="layui-form-item sp" style="float: left;">
            <p>优惠券名称：{$data.coupon_name}</p>
            <p>优惠券类型：{switch name="data.coupon_types"}
                {case value="1"}折扣券{/case}
                {case value="2"}满减券{/case}
                {default /}default
                {/switch}</p>
            <p>{if($data.coupon_types == 1 )}折扣{else/}满减金额{/if}：{$data.coupon_discount}</p>
            <p>总数：{$data.coupon_quantity}</p>
            <p>已领取：{$data.coupon_alreadyreceived}</p>
            {if($data.num_types == 1)}
            <p>剩余数：无限制</p>
            {else/}
            <p>剩余数：<?= $data['coupon_quantity']- $data['coupon_alreadyreceived']  ?></p>
            {/if}

            <p>活动状态：
                {switch name="data.coupon_status"}
                {case value=""}未知{/case}
                {case value="1"}未开始{/case}
                {case value="2"}进行中{/case}
                {case value="3"}已结束{/case}
                {case value="4"}停止中{/case}
                {default /}default
                {/switch}

            </p>
            <p>
                已使用：{$data.usenum}
            </p>
            <p>
                满减条件：{if($data.coupon_usecondition == 0)}无限制{else/}满{$data.coupon_usecondition}可使用{/if}
           </p>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;border:0">
        <div class="layui-form-item" style="float: left;">
            <form id="form1" class="layui-form serch" action="{:url('admin/coupon/details')}" method="post">
                <div class="layui-form-item" style="float: left;">
                    <!--<div class="layui-input-inline">-->
                        <!--<input type="text" name="phone" lay-verify="title" autocomplete="off" placeholder="联系电话" value="{if isset($where['goods_id'])}{$where['goods_id']}{/if}" class="layui-input layui-btn-sm">-->
                    <!--</div>-->
                    <input type="hidden" name="id" value="{$where['a.coupon_id']}">
                    <label class="layui-form-label">使用状态：</label>
                    <div class="layui-input-block">
                        <select name="usestatus" lay-search="">
                            <option value="" >全部</option>
                            <option value="0" >未使用</option>
                            <option value="1" >已使用</option>
                            <option value="2" >已过期</option>
                        </select>
                    </div>
                </div>
                <div style="float: left;margin-left: 20px">
                    <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>

                </div>

            </form>

        </div>
    </fieldset>
    <table class="layui-table" lay-even="" lay-skin="line">
        <colgroup>
            <col width="10%">
            <col width="10%">
            <col width="10%">
            <col width="10%">
        </colgroup>
        <thead>

        <tr>
            <th>领取人</th>
            <th>使用状态</th>
            <th>领取时间</th>
            <th>使用时间</th>

        </tr>
        </thead>
        <tbody>


{volist name='lie' id='vo'}

        <tr>
            <td>{empty name="$vo.member_nickname"}{$vo.member_phone}{else/}{$vo.member_nickname}{/empty}</td>
            <td>
                {switch name="$vo.usestatus"}
                {case value="0"}未使用{/case}
                {case value="1"}已使用{/case}
                {case value="2"}已过期{/case}
                {default /}default
                {/switch}

            </td>
            <td>{$vo.starttime|date='Y-m-d H:i:s',###}</td>
            <td>
                {if($vo.usestatus == 1 && !empty($vo.usetime))}
                {$vo.usetime|date='Y-m-d H:i:s',###}
                {else/}--{/if}
            </td>
        </tr>
{/volist}
        </tbody>
    </table>
    <div>{$lie->render()}</div>

    <script src="__PUBLIC__/layui/layui.js"></script>
    <script src="__PUBLIC__/jquery/jquery.min.js"></script>

    <script>
        var message;
        layui.config({
            base: '__JS__/',
            version: '1.0.1'
        }).use(['app', 'message'], function() {
            var app = layui.app,
                $ = layui.jquery,
                layer = layui.layer;
            //将message设置为全局以便子页面调用
            message = layui.message;
            //主入口
            app.set({
                type: 'iframe'
            }).init();
        });
    </script>
    <script type="text/javascript">

        $('.delete').click(function(){
            var id = $(this).attr('codeid');
            layer.confirm('确定要删除?', function(index) {
                $.ajax({
                    url:"{:url('admin/coupon/delcoupon')}",
                    data:{id:id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })
        $('.stop').click(function(){
            var id = $(this).attr('codeid');
            layer.confirm('是否确定操作？', function(index) {
                $.ajax({
                    url:"{:url('admin/coupon/stop')}",
                    data:{id:id},
                    success:function(res) {
                        layer.msg(res.msg);
                        if(res.code == 1) {
                            setTimeout(function(){
                                location.reload();
                            },1500)
                        }
                    }
                })
            })
        })



        // $('.copy').click(function(){
        //     var id = $(this).attr('codeid');
        //     layer.confirm('确定复制吗?', function(index) {
        //         $.ajax({
        //             url:"{:url('admin/trip/copytrip')}",
        //             data:{id:id},
        //             success:function(res) {
        //                 layer.msg(res.msg);
        //                 if(res.code == 1) {
        //                     setTimeout(function(){
        //                         location.reload();
        //                     },1500)
        //                 }
        //             }
        //         })
        //     })
        // })

    </script>
    <script type="text/javascript">
        layui.use('layer', function(){
            var layer = layui.layer;
            $('.a_menu').click(function(){
                var url = $(this).attr('href');
                var a = 0;
                $.ajax({
                    url:url
                    ,async:false
                    ,success:function(res){
                        if(res.code == 0) {
                            layer.msg(res.msg);
                            a = 1;
                        }
                    }
                })
                if(a === 0) {
                    layer.open({
                        type:2,
                        content:url,
                        area: ['700px', '680px'],
                        end:function(){
                            location.reload();
                        }
                    });
                }
                return false;
            })

            $('.preview').click(function(){
                var url = $(this).attr('href');
                layer.open({
                    type:2,
                    content:url,
                    area: ['550px', '400px']
                });
                return false;
            })
        });
    </script>

</body>
</html>
